package jalus.pojo;

import java.io.Serializable;
import java.util.Date;

import com.google.appengine.api.datastore.Blob;


/**
 * 文件存储
 * 
 *
 */
public class File implements Serializable{
	private static final long serialVersionUID = -4610608300307289206L;
	private Long id;
    private String fileName;
    private String mimeType;
    private byte[] content;
    private Date date;
    private int size;
	public File(Long id, String fileName, String mimeType, Blob content, Date date) {
		this.id = id;
		this.setContent(content.getBytes());
		this.fileName = fileName;
		this.mimeType = mimeType;
		this.setDate(date);
	}
	public File() {
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	public String getMimeType() {
		return mimeType;
	}
	public void setMimeType(String mineType) {
		this.mimeType = mineType;
	}
	public byte[] getContent() {
		return content;
	}
	public void setContent(byte[] content) {
		if(content!=null){
			this.size = content.length;
		}
		this.content = content;
	}
	public int getSize(){
		return this.size;
		
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Date getDate() {
		return date;
	}
	public String getShortFileName(){
		return this.fileName.substring(this.fileName.lastIndexOf('/')+1);
	}
	public void setSize(int size) {
		this.size = size;
	}
}
